<?php

namespace addons\demo\home\controller;

use addons\demo\common\model\Article;
use app\addon\AddonController;

class Index extends AddonController
{
    /**
     * @var Article
     */
    private $articleM;

    public function __construct()
    {
        parent::__construct();
        $this->articleM = new Article();
    }

    public function index()
    {
        $articles = $this->articleM->where('status', 1)
            ->order('view_num', 'desc')
            ->page(1, 10)
            ->select();
        return $this->show(['articles' => $articles]);
    }
}
